
/*
 * 导出报表.
 * @param {Object} prefix
 */
function exportReport(prefix){
	
	var str="";
	var checkArray = document.getElementsByName("chk");
	for (var i = 0; i < checkArray.length; i++) {
		if(checkArray[i].checked){
			var splitStr=checkArray[i].value.split("|");
			if(splitStr[0]!=null&&splitStr[0]!="")
				str += splitStr[0] + ",";
		}
	}
	var dot = str.lastIndexOf(",");
	if(dot==-1){
		layer.alert("请选择要导出的报表。");
		return;
	}else{
		str = str.substring(0,dot);
	}
	
	if(!window.confirm("确认导出？")){
		return;
	}
	
	//提交表单
	$("#exportIdStr").val(str);
	$("#exportForm").submit();
}

/*
 * 批量提交
 * @param {Object} prefix
 */
function setSubmitFlag(prefix){
	
	var str="";
	var checkArray = document.getElementsByName("chk");
	for (var i = 0; i < checkArray.length; i++) {
		if(checkArray[i].checked){
			var splitStr=checkArray[i].value.split("|");
			if(splitStr[0]!=null&&splitStr[0]!=""&&splitStr[1]!=null&&splitStr[1]==0)
				str += splitStr[0] + ",";
		}
	}
	var dot = str.lastIndexOf(",");
	if(dot==-1){
		layer.alert("请选择要提交的报表。");
		return;
	}else{
		str = str.substring(0,dot);
	}
	
	if(!window.confirm("确认提交？")){
		return;
	}
	
	var url=prefix+"/report/submit";
	$.post(url,{"checkStatus":"1","ids":str},function(data){
		layer.msg(data.message, 1, 1);
		if(data.result=="OK"){
			reSubmit();
		}
	},'json');
}

/*
 * 批量删除
 * @param {Object} prefix
 */
function setDeleteFlag(prefix){
	
	var str="";
	var checkArray = document.getElementsByName("chk");
	for (var i = 0; i < checkArray.length; i++) {
		if(checkArray[i].checked){
			var splitStr=checkArray[i].value.split("|");
			if(splitStr[0]!=null&&splitStr[0]!=""&&splitStr[1]!=null&&splitStr[1]==0)
				str += splitStr[0] + ",";
		}
	}
	var dot = str.lastIndexOf(",");
	if(dot==-1){
		layer.alert("请选择要删除的报表。");
		return;
	}else{
		str = str.substring(0,dot);
	}
	
	if(!window.confirm("确认删除？")){
		return;
	}
	
	var url=prefix+"/report/delete";
	$.post(url,{"ids":str},function(data){
		layer.msg(data.message, 1, 1);
		if(data.result=="OK"){
			reSubmit();
		}
	},'json');
}

/*
 * 设置为已导出状态.
 * @param {Object} prefix
 */
function setExportFlag(prefix){
	
	var str="";
	var checkArray = document.getElementsByName("chk");
	for (var i = 0; i < checkArray.length; i++) {
		if(checkArray[i].checked){
			str += checkArray[i].value + ",";
		}
	}
	var dot = str.lastIndexOf(",");
	if(dot==-1){
		layer.alert("请选择要设置状态的用户。");
		return;
	}else{
		str = str.substring(0,dot);
	}
	
	if(!window.confirm("确认执行？")){
		return;
	}
	
	var url=prefix+"/report/exportOverUser";
	$.post(url,{"idStr":str,},function(data){
		layer.msg(data.message, 1, 1);
		if(data.result=="OK"){
			location.reload(true);
		}
	},'json');
	
}